// 登录接口
import {request} from '../utils/request'

const questionApi = {
  adminLogin: '/login/admin',
  teacherLogin: '/login/teacher',
  studentLogin: '/login/student',
  studentComplete: '/userInfo/student/complete',
  teacherComplete: '/userInfo/teacher/complete',
  getCaptcha: '/login/getCaptcha'
}

// 管理员登录
export function adminLogin (userInfo) {
  return request({
    url: questionApi.adminLogin,
    method: 'post',
    data: {
      account: userInfo.id,
      password: userInfo.password,
      captcha: userInfo.captcha
    }
  })
}

// 老师登录
export function teacherLogin (userInfo) {
  return request({
    url: questionApi.teacherLogin,
    method: 'post',
    data: {
      account: userInfo.id,
      password: userInfo.password,
      captcha: userInfo.captcha
    }
  })
}

// 学生登录
export function studentLogin (userInfo) {
  return request({
    url: questionApi.studentLogin,
    method: 'post',
    data: {
      account: userInfo.id,
      password: userInfo.password,
      captcha: userInfo.captcha
    }
  })
}

export function studentComplete (map) {
  return request({
    url: questionApi.studentComplete,
    method: 'post',
    params: {
      studentNumber: sessionStorage.getItem('studentNumber')
    },
    data: {
      name: map.name
    }
  })
}

export function teacherComplete (map) {
  return request({
    url: questionApi.teacherComplete,
    method: 'post',
    params: {
      teacherNumber: sessionStorage.getItem('teacherNumber')
    },
    data: {
      name: map.name
    }
  })
}

export function getCaptcha (d) {
  return request({
    url: questionApi.getCaptcha,
    method: 'get',
    responseType: 'blob',
    params: {
      d: d
    }
  })
}
